package com.irenty.effectivej.ch02.objectreation;

import java.util.logging.Logger;

import org.testng.annotations.Test;

/*
 * Item 4: Enforce noninstantiability with a private constructor
 */
public class NoninstantiableUtilityClassTest {
	private final static Logger LOGGER = Logger
			.getLogger(NoninstantiableUtilityClassTest.class.getName());

	// Noninstantiable utility class
	public static class UtilityClass {
		// Suppress default constructor for noninstantiability
		private UtilityClass() {
			// throw an exception so even with reflection you will not success,
			// provides insurance in case the constructor is accidentally invoked from within the class
			throw new AssertionError();
		}

		public static void doSomething() {
			LOGGER.info("Doing something");
		}
	}

	@Test
	public void testBooleans() throws Exception {
		UtilityClass.doSomething();
	}
}
